Replace Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Replace all items in a collection equal to a particular value with another values, yielding another collection. A passed IEqualityComparer is used to determine equality.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T> Replace<T>(
	IEnumerable<T> collection,
	T itemFind,
	T replaceWith,
	IEqualityComparer<T> equalityComparer
)
Visual Basic (Declaration)
Public Shared Function Replace(Of T) ( _
	collection As IEnumerable(Of T), _
	itemFind As T, _
	replaceWith As T, _
	equalityComparer As IEqualityComparer(Of T) _
) As IEnumerable(Of T)
Visual C++
public:
generic<typename T>
static IEnumerable<T>^ Replace (
	IEnumerable<T>^ collection, 
	T itemFind, 
	T replaceWith, 
	IEqualityComparer<T>^ equalityComparer
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection to process.
itemFind
T
The value to find and replace within collection.
replaceWith
T
The new value to replace with.
equalityComparer
IEqualityComparer<(Of <T>)>
The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called.

Return Value

An new collection with the items from collection, in the same order, with the appropriate replacements made.

Type Parameters

T

See Also